package pers.qianyu.module.system.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.qianyu.module.core.comm.HttpResult;
import pers.qianyu.module.core.comm.Pagination;
import pers.qianyu.module.core.domain.system.query.SysResourceQuery;
import pers.qianyu.module.core.domain.system.vo.SysResourceVO;
import pers.qianyu.module.system.service.SysResourcesService;

/**
 * @author mizzle rain
 * @date 2021-05-03 22:24
 */
@Api(tags = "资源相关接口")
@RestController
@RequestMapping("/system-serv")
public class SysResourceController {
    @Autowired
    private SysResourcesService sysResourcesService;

    @ApiOperation("根据资源id查询资源信息")
    @GetMapping("/resource/{id}")
    public HttpResult<SysResourceVO> queryById(@PathVariable Long id) {
        SysResourceVO sysResourceVO = sysResourcesService.queryById(id);
        return HttpResult.okWithData(sysResourceVO);
    }

    @ApiOperation("查询所有资源列表")
    @GetMapping("/resources")
    public HttpResult<Pagination<SysResourceVO>> query(SysResourceQuery sysResourceQuery) {
        Pagination<SysResourceVO> pagination = sysResourcesService.query(sysResourceQuery);
        return HttpResult.okWithData(pagination);
    }
}
